import 'package:adaptive_dialog/adaptive_dialog.dart';
import 'package:get/get.dart';
import 'package:sainbainu/common/services/jverify.dart';
import 'package:sainbainu/common/services/user.dart';
import 'package:sainbainu/common/routes/routes.dart';
import 'package:sainbainu/common/utils/loading.dart';

import 'index.dart';

class SettingsController extends GetxController {
  SettingsController();

  final state = SettingsState();

  @override
  void onInit() {
    super.onInit();
  }

  @override
  void onReady() {
    super.onReady();
  }

  @override
  void onClose() {
    super.onClose();
  }

  /// 退出登录
  Future<void> handleLogout() async {
    final OkCancelResult res = await showOkCancelAlertDialog(
      context: Get.context!,
      title: '退出登录',
      message: '确定要退出登录该账号？',
      okLabel: '确定',
      cancelLabel: '取消',
      style: AdaptiveStyle.iOS,
      isDestructiveAction: true,
    );
    if (res == OkCancelResult.ok) {
      UserService.to.setIsLogin(false);
      UserService.to.setToken(null);
      Get.back();
    }
  }
}
